#ifndef FORMCHILDOPERATIONLOG
#define FORMCHILDOPERATIONLOG

#include <QWidget>
#include <QVector>
#include "../database/datahandle.h"
class QTreeWidgetItem;
class QTableWidgetItem;
class QTreeWidget;
class QTableWidget;
class QPushButton;
class QStringList;
class QLineEdit;
class QDateEdit;

// 运行日志类

class OperationRunLog : public QWidget
{
    Q_OBJECT
public:
    OperationRunLog(QWidget * parent = 0);
    void clearRunLog();
public slots:
    void slotRunLot(QString str);
private:
    void setRunLog(const QString &strLog);

private:
    QTreeWidget * m_pRunLogWin;
    QVector<QTreeWidgetItem *> m_logItemsVector;
};

// 记录类
class OperationRecord : public QWidget
{
    Q_OBJECT
public:
    OperationRecord(QStringList strList,QWidget * parent = 0);
public slots:
    void slotAddOneRow(QStringList strList);
    void slotDelOneRow(QString plate,QString name);
    void slotModifyOneRow(QStringList strList);
    void slotClearAllRow();
signals:
    void sigItemClicked(QStringList strList);

private:
    void createWin();
    void setConnection();
    bool comparePlateAndOwnner(int row,QString plate,QString ownner);
    bool deleteRow(int row);
    void modifyRow(int row,QStringList strList);

private slots:
    // 响应 m_pRecordTbl 的cellClicked信号
    void slotItemClicked(int row, int column);

private:
    QStringList    m_strHeadNameList;
    QTableWidget * m_pRecordTbl;
    int  m_iRow;
};


class RecordInterface : public QWidget
{
    Q_OBJECT
public:
    RecordInterface(bool isInner, QWidget * parent = 0);

public slots:
    void slotItemClicked(QStringList strList);

signals:
    void sigMsg(QString str);

signals:
    void sigRecordSelect(QStringList strList);
    void sigRecordAdd(QStringList strList);
    void sigRecordDelete(QString plate,QString name);
    void sigRecordModify(QStringList strList);
    void sigRecordClear();

private:
    void createWin();
    void setConnect();
    void modifyShow(bool isShow);
    void clearEdit();

private slots:
    void slotSelect();
    void slotAdd();
    void slotDelete();
    void slotModify();
    void slotClear();
private:
    bool m_bIsInner;

    QPushButton *m_pSelectBtn;
    QPushButton *m_pAddBtn;
    QPushButton *m_pDeleteBtn;
    QPushButton *m_pModifyBtn;
    QPushButton *m_pClearBtn;

    QLineEdit   *m_pPlateEdit;
    QLineEdit   *m_pOwnnerEdit;
    QLineEdit   *m_pOwnnerTelEdit;
    QDateEdit   *m_pStartTime;
    QDateEdit   *m_pEndTime;
//    QLineEdit   *m_pOperateTime;
    QLineEdit   *m_pChargeMoneyEdit;

};

// 期卡管理
class InnerFileManage : public QWidget
{
    Q_OBJECT
public:
    InnerFileManage(QWidget *parent = 0);
private:
    void createWin();
    void setConnection();
signals:
    void sigMsg(QString str);
private:
    RecordInterface *m_pInnerInterface;
    OperationRecord *m_pInnerRecord;
};

// 月卡管理
class MonthFileManage : public QWidget
{
    Q_OBJECT
public:
    MonthFileManage(QWidget *parent=0);
signals:
    void sigMsg(QString str);
private:
    void createWin();
    void setConnection();
private:
    RecordInterface *m_pMonthInterface;
    OperationRecord *m_pMonthRecord;
};

#endif // FORMCHILDOPERATIONLOG

